package com.hksj.dpm.controller;

import com.hksj.base.query.AlarmQuery;
import com.hksj.base.query.BaseRecordQuery;
import com.hksj.base.vo.AlarmNumVO;
import com.hksj.common.core.model.Rest;
import com.hksj.dpm.query.DpmDailyAlarmQuery;
import com.hksj.dpm.query.DpmAlarmQuery;
import com.hksj.dpm.query.DpmSpecialityQuery;
import com.hksj.dpm.query.PressureRankQuery;
import com.hksj.dpm.service.DpmService;
import com.hksj.dpm.vo.CurrentAlarmInfoVO;
import com.hksj.dpm.vo.DpmDailyAlarmNumVO;
import com.hksj.dpm.vo.DpmDeviceStatusVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "压差监测-报警记录")
@RestController
@RequestMapping("/api/dpm/alarm")
public class DpmAlarmController {
    @Autowired
    private DpmService dpmService;

    @ApiOperation("获取设备总报警总数")
    @PostMapping("/getAlarmTotalNum")
    public Rest<AlarmNumVO> getAlarmTotalNum(@RequestBody DpmAlarmQuery query){
        AlarmNumVO res = dpmService.getAlarmTotalNum(query);
        return Rest.ok(res);
    }

    @ApiOperation("大屏-当前报警设备情况")
    @PostMapping("/getCurrentAlarmInfo")
    public Rest<CurrentAlarmInfoVO> getCurrentAlarmInfo(@RequestBody DpmSpecialityQuery query){
        CurrentAlarmInfoVO res = dpmService.getCurrentAlarmInfo(query);
        return Rest.ok(res);
    }

    @ApiOperation("大屏-最近7天报警次数")
    @PostMapping("/listDailyAlarmNum")
    public Rest<List<DpmDailyAlarmNumVO>> listDailyAlarmNum(@RequestBody DpmDailyAlarmQuery query){
        List<DpmDailyAlarmNumVO> list = dpmService.listDailyAlarmNum(query);
        return Rest.ok(list);
    }

    @ApiOperation("大屏-设备压力排名(前五)")
    @PostMapping("/listPressureRank")
    public Rest<List<DpmDeviceStatusVO>> listPressureRank(@RequestBody PressureRankQuery query){
        List<DpmDeviceStatusVO> list = dpmService.listPressureRank(query);
        return Rest.ok(list);
    }

    @ApiOperation("报警记录-导出")
    @PostMapping("/exportAlarm")
    public void exportAlarm(@RequestBody AlarmQuery query, HttpServletResponse response){
        dpmService.exportAlarm(query,response);
    }
}
